<template>
	<view>
		<view style="text-align: center;font-size: 20px;font-weight: 900;height: 40px;line-height: 40px">崇教干训欢迎您！
		</view>
		<view>
			<uni-swiper-dot class="uni-swiper-dot-box" :info="data" :current="current" field="content">
				<swiper class="swiper-box" :current="swiperDotIndex" circular="true" @change="changeSwiper"
					autoplay="true">
					<swiper-item v-for="(item, index) in data" :key="index">
						<view class="swiper-item" @click="clickBannerItem(item)">
							<image :src="baseUrl+item.image" mode="aspectFill" style="height: 150px;"
								:draggable="false" />
						</view>
					</swiper-item>
				</swiper>
			</uni-swiper-dot>
		</view>
		<view class="container">
			<uni-list>
				<uni-list-item v-for="(item, index) in journalismData" :key="index" :title="item.title"
					:note="item.detailedContent" showArrow :thumb="baseUrl+item.imgUrl" thumb-size="lg" rightText="查看"
					@click="toUrl(item)" clickable />
			</uni-list>
		</view>
		

	</view>
</template>

<script>
	import config from '@/config'
	import {
		getInfoId,
		getInforoleKey
	} from '@/utils/auth';
	import {
		listImages
	} from '@/api/jz/appHome/images.js';
	import {
		listInfo as journalismList
	} from '@/api/jz/journalism/info.js';

	export default {
		data() {
			return {
				baseUrl: config.baseUrl,
				current: 0,
				swiperDotIndex: 0,
				journalismData: [],
				data: [{
						image: '/static/images/banner/banner01.png'
					},
					{
						image: '/static/images/banner/banner02.png'
					},
					{
						image: '/static/images/banner/banner03.png'
					}
				],
			}
		},
		onLoad: function() {

			this.listImagesFun();
			this.journalismListFun();
		},
		mounted() {
			
		},

		onShow() {

			if (getInforoleKey() === "student" && (getInfoId() == null || getInfoId() == "")) {
				uni.showModal({
					title: '提示',
					content: '请前往我的完善个人资料',
					cancelText: "取消", // 取消按钮的文字
					confirmText: "确认", // 确认按钮的文字
					showCancel: false, // 是否显示取消按钮，默认为 true
					confirmColor: '#39B54A',
					cancelColor: '#39B54A',
					success: (res) => {
						if (res.confirm) {
							this.$tab.navigateTo("/pages/mine/info/edit")
						} else {}
					}
				})
			}


			if (getInforoleKey() === "school::substrate" && (getInfoId() == null || getInfoId() === "")) {
				uni.showModal({
					title: '提示',
					content: '请前往完善学校信息',
					cancelText: "取消", // 取消按钮的文字
					confirmText: "确认", // 确认按钮的文字
					showCancel: false, // 是否显示取消按钮，默认为 true
					confirmColor: '#39B54A',
					cancelColor: '#39B54A',
					success: (res) => {
						if (res.confirm) {
							this.$tab.navigateTo("/pages/mine/school/index")
						} else {}
					}
				})
			}


		},
		updated() {

		},
		methods: {
			toUrl(data) {
				uni.navigateTo({
					url: '/pages/threePage/threePage?url=' + data.url
				})
			},
			journalismListFun() {
				journalismList().then(res => {
					if (res.code === 200) {
						this.journalismData = res.rows
					}
				})
			},
			listImagesFun() {
				listImages().then(res => {
					if (res.code === 200) {
						this.data = res.rows
					}
				})
			},
			changeSwiper(e) {
				this.current = e.detail.current
			},
			clickBannerItem(item) {
				console.info(item)
			},
			


		}
	}
</script>

<style lang="scss">
	/* #ifndef APP-NVUE */
	page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		background-color: #fff;
		min-height: 100%;
		height: auto;
	}
	
	view {
		font-size: 14px;
		line-height: inherit;
	}

	/* #endif */

	.text {
		text-align: center;
		font-size: 26 rpx;
		margin-top: 10 rpx;
	}

	.grid-item-box {
		flex: 1;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 15px 0;
	}

	.uni-margin-wrap {
		width: 690 rpx;
		width: 100%;
	}

	.swiper {
		height: 300 rpx;
	}

	.swiper-box {
		height: 150px;
	}

	.swiper-item {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		align-items: center;
		color: #fff;
		height: 300 rpx;
		line-height: 300 rpx;
	}

	@media screen and (min-width: 500px) {
		.uni-swiper-dot-box {
			width: 400px;
			/* #ifndef APP-NVUE */
			margin: 0 auto;
			/* #endif */
			margin-top: 8px;
		}

		.image {
			width: 100%;
		}
	}

	.slot-box {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
	}

	.slot-image {
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		margin-right: 10px;
		width: 30px;
		height: 30px;
	}

	.slot-text {
		flex: 1;
		font-size: 14px;
		color: #4cd964;
		margin-right: 10px;
	}
</style>